#include "Player.h"


Player::Player(ID2D1Bitmap *tex) : speed(5)
{
	playerSprite = new Sprite(tex,100,100);
	size.width = 100;
	size.height = 100;
	
	facingDir.width=0;
	facingDir.height=0;

	phyObj.position.width = 100;
	phyObj.position.height = 100;
	phyObj.matrix = D2D1::Matrix3x2F::Identity();
}


Player::~Player()
{
	delete playerSprite;
}

void Player::Render(ID2D1HwndRenderTarget* render)
{
	playerSprite->Render(phyObj.matrix, render);
}

void Player::Update(long elapsedTime)
{
	/*FLOAT normalize = fabs(facingDir.width)+fabs(facingDir.height);
	if(normalize!=0)
	{
		facingDir.width /= normalize;
		facingDir.height /= normalize;
	}*/

	/*position.width+=facingDir.width*speed;
	position.height+=facingDir.height*speed;
	phyObj.center.x+=facingDir.width*speed;
	phyObj.center.y+=facingDir.height*speed;*/
	phyObj.velocity = D2D1::SizeF(facingDir.width*speed, facingDir.height*speed);
	phyObj.phyWorld->UpdateObject(phyObj);

	facingDir.width = 0;
	facingDir.height = 0;
}

void Player::Move(D2D1_SIZE_F _facingDir)
{
	facingDir.width += _facingDir.width;
	facingDir.height += _facingDir.height;
}

void Player::Rotate(FLOAT _angle)
{
	phyObj.angle = _angle;
}